package com.example.rk.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDateConverter implements Converter<String, Date> {

    @Override
    //2022-07-08-89
    public Date convert(String source) {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date target = sdf.parse(source);
            return target;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println("MyDateConverter.convert() 转换失败,source="+source);
        return null;
    }
}
